/**
  * 打游戏面板
  * by dq
  * (c) copyright 2016-09-19
  * All Rights Reserved. 
  */
module qznn {

    export class PlayWaitMediatorQZNN extends BaseMediator {
        public static NAME: string = "PlayWaitMediatorQZNN";

        private _playerGroup: Array<any> = [];
        private _playersitGroup: Array<any> = [];
        private _playerzhuang: Array<number> = [0, 0, 0, 0, 0];

        private _choseZhuang: Array<number> = [];
        public static interval: any = null;//出牌倒计时；

        private time: egret.Timer = null;
        private timeOutArr = [];


        private qiangArr: Array<number> = [];
        private time2: egret.Timer = null;
        private conut: number = 0;
        private aniTime: number = 0;

        private isXiaZhuWait: boolean = false;

        private Poker_DDZArr: Array<number> = [];

        public constructor(viewComponent: any = null) {
            super(PlayWaitMediatorQZNN.NAME, viewComponent);
        }
        public listNotificationInterests(): Array<any> {
            return [
                PanelNotify.HALL.STAGE_RESIZE,
                PanelNotify.QZNN.CLOSE_PLAY_WAIT_GAME,
                PanelNotify.QZNN.PLAYER_SITDOWN,
                PanelNotify.QZNN.JOIN_ROOM,
                PanelNotify.QZNN.SINGLE_PLAYER_QIANG_ZHUANG,
                PanelNotify.QZNN.XIANJIA_XIAZHU,
                PanelNotify.QZNN.START_QIANGZHUANG,
                PanelNotify.QZNN.PLAYER_ADDTIME,
                PanelNotify.QZNN.PLAYER_LEAVE,
                PanelNotify.QZNN.SHOWCARD,
                PanelNotify.QZNN.SINGLE_GAME_END,
                PanelNotify.QZNN.SHOW_ALLCARD,
                PanelNotify.QZNN.CLEAR_TABLE,
                PanelNotify.QZNN.SETDIFEN,
                PanelNotify.QZNN.WANJIATAMPAI,
                PanelNotify.QZNN.RELINKINQIANGZHUANG,
                PanelNotify.QZNN.GET_SERIAL_NUMBER,
                PanelNotify.QZNN.RELINKINXIAZHU,
                PanelNotify.QZNN.RELINKINTANPAI,
                PanelNotify.QZNN.CLOSE_PLAY_GAME,
            ]
        }
        public playWaitPanel: PlayWaitPanelQZNN;//基础面板

        public handleNotification(notification: puremvc.INotification): void {
            switch (notification.getName()) {
                case PanelNotify.HALL.STAGE_RESIZE:
                    if (this.playWaitPanel) {
                        this.playWaitPanel.width = GameConfig.curWidth()
                        this.playWaitPanel.height = GameConfig.curHeight()
                    }
                    break;
                case PanelNotify.QZNN.CLOSE_PLAY_WAIT_GAME: {
                    this.closePanel(0);
                    break;
                }
                case PanelNotify.QZNN.JOIN_ROOM:
                    if (this.playWaitPanel && this.playWaitPanel.parent) {
                        this.initUserInfo();
                    } else {//游戏中途加入有可能 先进玩家后加载房间数据，这时候面板还没起来。后台BUG
                        this.playWaitPanel = null;
                        this.playWaitPanel = new PlayWaitPanelQZNN();
                        this.showUI(this.playWaitPanel, 2, 5);
                        game.AppFacade.instance.sendNotification(PanelNotify.HALL.JOIN_GAME_BY_HALL)
                    }
                    break;
                case PanelNotify.QZNN.PLAYER_SITDOWN:
                    if (!this.playWaitPanel) {
                        this.playWaitPanel = null;
                        this.playWaitPanel = new PlayWaitPanelQZNN();
                        this.showUI(this.playWaitPanel, 1, 0);
                        game.AppFacade.instance.sendNotification(PanelNotify.HALL.JOIN_GAME_BY_HALL)
                    }
                    this.playerGetFromTotal(notification.getBody());
                    break;
                case PanelNotify.QZNN.SINGLE_PLAYER_QIANG_ZHUANG:
                    this.handleSinglePlayerQiangZhuangReturn(notification.getBody());
                    break;
                case PanelNotify.QZNN.XIANJIA_XIAZHU:
                    this.StartXianJiaXiaZhu(notification.getBody());
                    break;
                case PanelNotify.QZNN.START_QIANGZHUANG:
                    egret.setTimeout(() => { this.startQiangzhuang() }, this, 500)
                    break;
                case PanelNotify.QZNN.PLAYER_ADDTIME:
                    this.playerAddtime(notification.getBody());
                    break;
                case PanelNotify.QZNN.PLAYER_LEAVE:
                    this.playerLeave(notification.getBody());
                    break;
                case PanelNotify.QZNN.SHOWCARD:
                    // this.PlayerFapaiDonghua();
                    this.ShowPlayerCard(notification.getBody());
                    break;
                case PanelNotify.QZNN.SHOW_ALLCARD:
                    this.ShowAllCard();
                    break;
                case PanelNotify.QZNN.CLEAR_TABLE:
                    this.ClearTabel();
                    break;
                case PanelNotify.QZNN.SETDIFEN:
                    this.playWaitPanel.rule_difen.text = "底注：" + QznnVO.getVo().difen / 100;
                    this.playWaitPanel.dizhu.text = "底注：" + QznnVO.getVo().difen / 100;
                    break;
                case PanelNotify.QZNN.WANJIATAMPAI:
                    this.PlayerPrepareTanpai(notification.getBody());
                    break;
                case PanelNotify.QZNN.RELINKINQIANGZHUANG:
                    this.RelinkinQiangZHuang(notification.getBody());
                    break;
                case PanelNotify.QZNN.RELINKINXIAZHU:
                    this.RelinkinXiaZhu(notification.getBody());
                    break;
                case PanelNotify.QZNN.RELINKINTANPAI:
                    this.RelinkinTanpai(notification.getBody());
                    break;
                case PanelNotify.QZNN.CLOSE_PLAY_GAME:
                    this.ClosePlayGame();
                    break;
                case PanelNotify.QZNN.GET_SERIAL_NUMBER:
                    this.initRoomInfo();
                    break;
            }
        }

        /**
         * 初始化面板ui
         */
        public initUI(): void {
            Global.removeTimeOut(this.timeOutArr)
            // game.AppFacade.instance.sendNotification(PanelNotify_public.CLOSE_MAP);
            // egret.Tween.removeAllTweens();
            //切换音乐
            if (InstructionsEnum.SOUND_GAME != InstructionsEnum.GAME_SOUND_NAME.QZNN) {
                SoundManage.stopYinYue();
                InstructionsEnum.SOUND_GAME = InstructionsEnum.GAME_SOUND_NAME.QZNN
                SoundManage.startYinYueLoad();
            }
            //将滚动公告转移到当前面板
            EffectUtils.moveNoticeToPanel(this.playWaitPanel.noticeGroup)
            this.playWaitPanel.menu_button.addEventListener(egret.TouchEvent.TOUCH_TAP, this.menu_click, this)
            this.playWaitPanel.menu_fankui.addEventListener(egret.TouchEvent.TOUCH_TAP, this.fankuiClick, this)
            this.playWaitPanel.menu_jilu.addEventListener(egret.TouchEvent.TOUCH_TAP, this.jiluClick, this)
            this.playWaitPanel.menu_set.addEventListener(egret.TouchEvent.TOUCH_TAP, this.setClick, this)
            this.playWaitPanel.menu_help.addEventListener(egret.TouchEvent.TOUCH_TAP, this.helpClick, this)
            this.playWaitPanel.menu_exit.addEventListener(egret.TouchEvent.TOUCH_TAP, this.exitClick, this)

            this.playWaitPanel.btn_meiniu.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onBtnmeiniuClick, this);
            this.playWaitPanel.btn_youniu.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onBtnyouniuClick, this);
            this.playWaitPanel.zhunbei.addEventListener(egret.TouchEvent.TOUCH_TAP, this.zhunbeiClick, this)

            for (let i = 0; i < 5; i++) {
                this.playWaitPanel["poker_My" + i].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onMyPoker_DDZClicke, this);
            }
            for (let i = 1; i < 5; i++) {
                this.playWaitPanel["jiao_" + i].addEventListener(egret.TouchEvent.TOUCH_TAP, this.clickBet, this);
            }
            this.time = new egret.Timer(1000);
            this.time.addEventListener(egret.TimerEvent.TIMER, this.TimeCutDown, this);
            this.time2 = new egret.Timer(100, 8);
            this.time2.addEventListener(egret.TimerEvent.TIMER, this.Time2CutDown, this)
            this.playWaitPanel.CountDownBg.visible = true;
            this.playWaitPanel.CountDownText.text = "12";

            // for (let i = 0; i < 5; i++) {
            //     this.playWaitPanel["btn_" + i].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onStartXianJiaXiaZhu, this);
            //     this.playWaitPanel["btn_" + i].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onQiangzhuang, this);
            // }
        }

        /**
         * 初始化面板数据
         */
        public initData(): void {
            InstructionsEnum.isHall = true;
            this.ClearTabel();
            this.playWaitPanel.CountDownBg.visible = true;
            this.playWaitPanel.CountDownText.visible = true;
            this.playWaitPanel.CountDownText.text = "13";
            this.time.start();
            this.initRoomInfo();
            this.initUserInfo();
            this.playWaitPanel.btn_meiniu.visible = false;
            this.playWaitPanel.btn_youniu.visible = false;
        }
        // 初始化房间信息
        private initRoomInfo() {

            this.playWaitPanel.dizhu.text = "底注：" + QznnVO.getVo().difen / 100;
            this.playWaitPanel.bianhao.text = "局号：" + QznnVO.getVo().gameNumbering;
        } 22
        //初始化玩家信息
        private initUserInfo() {
            //玩家信息
            this.playWaitPanel.player1.lab_name.text = Global.cutString(GameVO.getVo().szNickName);
            this.playWaitPanel.player1.img_head.source = "special_" + (GameVO.getVo().wFaceID % 15);
            this.playWaitPanel.player1.blab_score.text = this.SortGold(QznnVO.getVo().lUserScore) + "";
            this.playWaitPanel.player1.visible = true
            if (QznnVO.getVo().myReadyStatus === 3) {//已准备
                this.playWaitPanel.img_zhunbei1.visible = true;

            } else {
                this.playWaitPanel.img_zhunbei1.visible = false;
            }
            if (QznnVO.getVo().myReadyStatus === 2) {//未准备
                if (this.aniTime) {
                    if (this.playWaitPanel.zhunbei.visible == false) {
                        this.playWaitPanel.zhunbei.visible = true;
                        this.playWaitPanel.CountDownBg.visible = true;
                        this.playWaitPanel.CountDownText.visible = true;
                        this.playWaitPanel.CountDownText.text = (13 - this.aniTime) + "";
                        // this.playWaitPanel.rule_difen.text = 
                        // this.time.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.TimeCutDownStop, this);
                        this.time.stop();
                        this.time.reset();
                        this.time.start();
                    }

                }
            } else {
                this.playWaitPanel.zhunbei.visible = false;
            }

            if (Global.isNotEmpty(QznnVO.getVo().leftChairID)) {
                if (QznnVO.getVo().leftGlod == 0) {
                    this.playWaitPanel.player0.visible = false;
                }
                else {
                    this.playWaitPanel.player0.lab_name.text = Global.cutString(QznnVO.getVo().leftName);
                    this.playWaitPanel.player0.img_head.source = "special_" + QznnVO.getVo().leftSource % 15;
                    this.playWaitPanel.player0.blab_score.text = this.SortGold(QznnVO.getVo().leftGlod) + "";
                    // console.log(this.playWaitPanel.player0.blab_score.text)
                    if (QznnVO.getVo().leftReadyStatus === 3) {//已准备
                        this.playWaitPanel.img_zhunbei0.visible = true;
                    } else {
                        this.playWaitPanel.img_zhunbei0.visible = false;
                    }
                    this.playWaitPanel.player0.setXY(0)
                    this.playWaitPanel.player0.visible = true
                }

            } else {
                this.playWaitPanel.player0.visible = false
            }

            if (Global.isNotEmpty(QznnVO.getVo().rightChairID)) {
                if (QznnVO.getVo().rightGlod == 0) {
                    this.playWaitPanel.player2.visible = false;
                } else {
                    this.playWaitPanel.player2.lab_name.text = Global.cutString(QznnVO.getVo().rightName);
                    this.playWaitPanel.player2.img_head.source = "special_" + (GameVO.getVo().wFaceID % 15);
                    this.playWaitPanel.player2.blab_score.text = this.SortGold(QznnVO.getVo().rightGlod) + "";
                    if (QznnVO.getVo().rightReadyStatus === 3) {//已准备
                        this.playWaitPanel.img_zhunbei2.visible = true;
                    } else {
                        this.playWaitPanel.img_zhunbei2.visible = false;
                    }

                    this.playWaitPanel.player2.setXY(2)
                    this.playWaitPanel.player2.visible = true
                }

            } else {
                this.playWaitPanel.player2.visible = false
            }

            if (Global.isNotEmpty(QznnVO.getVo().upChairID)) {
                if (QznnVO.getVo().upGlod == 0) {
                    this.playWaitPanel.player3.visible = false;
                }
                else {
                    this.playWaitPanel.player3.lab_name.text = Global.cutString(QznnVO.getVo().rightName);
                    this.playWaitPanel.player3.img_head.source = "special_" + (GameVO.getVo().wFaceID % 15);
                    this.playWaitPanel.player3.blab_score.text = this.SortGold(QznnVO.getVo().upGlod) + "";
                    if (QznnVO.getVo().upReadyStatus === 3) {//已准备
                        this.playWaitPanel.img_zhunbei3.visible = true;
                    } else {
                        this.playWaitPanel.img_zhunbei3.visible = false;
                    }

                    this.playWaitPanel.player3.setXY(3)
                    this.playWaitPanel.player3.visible = true
                }

            } else {
                this.playWaitPanel.player3.visible = false
            }
        }

        //整理金币显示文本
        private SortGold(gold: number): string {
            let tmp = gold / 100;
            let str = ""
            if (tmp > 100000) {
                str = (tmp / 10000).toFixed(2) + "万";
                return str;
            }
            else {
                str = tmp + "";
                return str;
            }
        }

        //整理名字
        // private SortName(name: string): string {
        //     // if(name)
        //     let count = 0;
        //     for (let i = 0; i < name.length; i++) {
        //         if (name.charCodeAt(i) < 127) {
        //             count++;
        //             if (count > 10) {
        //                 if (name.charCodeAt(i - 1) < 127) {
        //                     return name.slice(0, i - 2) + "..";
        //                 }
        //                 else {
        //                     return name.slice(0, i - 1) + "..";
        //                 }
        //             }
        //         }
        //         else {
        //             count++;
        //             count++;
        //             if (count > 10) {
        //                 if (name.charCodeAt(i - 1) > 127) {
        //                     return name.slice(0, i - 1) + "..";
        //                 }
        //                 else {
        //                     if (count - 2 < 10) {
        //                         return name.slice(0, i - 1) + "..";
        //                     }
        //                     else {
        //                         return name.slice(0, i - 2) + "..";
        //                     }
        //                 }
        //                 // return name.slice(0, i - 1) + "..";
        //             }
        //         }
        //     }
        //     return (name);
        // }
        //退出游戏
        private ClosePlayGame(): void {

            InstructionsEnum.isHall = false;
            // egret.Tween.removeAllTweens();
            if (this.time)
                this.time.stop();
            if (this.time2)
                this.time2.stop();
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.CLOSE_HELP);
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.CLOSE_USER_LIST);
            this.closePanel(1);
        }


        //下注重连
        private RelinkinXiaZhu(data: any): void {
            var thisObj = this;
            if (data["wBankerUser"] != QznnVO.getVo().leftChairID) {
                thisObj.playWaitPanel.player0.img_zhuang.visible = false
                thisObj.playWaitPanel.player0.img_headbg.visible = false
            }
            else {
                thisObj.playWaitPanel.player0.img_zhuang.visible = true;
                thisObj.playWaitPanel.player0.img_headbg.visible = true;
            }
            if (data["wBankerUser"] != QznnVO.getVo().upChairID) {
                thisObj.playWaitPanel.player3.img_zhuang.visible = false
                thisObj.playWaitPanel.player3.img_headbg.visible = false
            }
            else {
                thisObj.playWaitPanel.player3.img_zhuang.visible = true;
                thisObj.playWaitPanel.player3.img_headbg.visible = true;
            }
            if (data["wBankerUser"] != QznnVO.getVo().rightChairID) {
                thisObj.playWaitPanel.player2.img_zhuang.visible = false
                thisObj.playWaitPanel.player2.img_headbg.visible = false
            }
            else {
                thisObj.playWaitPanel.player2.img_zhuang.visible = true;
                thisObj.playWaitPanel.player2.img_headbg.visible = true;
            }
            if (data["wBankerUser"] != QznnVO.getVo().wChairID) {
                thisObj.playWaitPanel.player1.img_zhuang.visible = false
                thisObj.playWaitPanel.player1.img_headbg.visible = false
            }
            else {
                thisObj.playWaitPanel.player1.img_zhuang.visible = true;
                thisObj.playWaitPanel.player1.img_headbg.visible = true;
            }

            if (data.lTableScore[QznnVO.getVo().wChairID]) {
                this.playWaitPanel.img_player1.source = "qznn_bet_" + (Number(data["cbAddTimes"]) / Number(QznnVO.getVo().difen));
                this.playWaitPanel.img_player1.visible = true;
                this.playWaitPanel.jiaofen_group.visible = false;
            }
            else if (data.lTableScore[QznnVO.getVo().leftChairID]) {
                this.playWaitPanel.img_player0.source = "qznn_bet_" + (Number(data["cbAddTimes"]) / Number(QznnVO.getVo().difen));
                this.playWaitPanel.img_player0.visible = true;

            }
            else if (data.lTableScore[QznnVO.getVo().rightChairID]) {

                this.playWaitPanel.img_player2.source = "qznn_bet_" + (Number(data["cbAddTimes"]) / Number(QznnVO.getVo().difen));
                this.playWaitPanel.img_player2.visible = true;

            }
            else if (data.lTableScore[QznnVO.getVo().upChairID]) {

                this.playWaitPanel.img_player3.source = "qznn_bet_" + (Number(data["cbAddTimes"]) / Number(QznnVO.getVo().difen));
                this.playWaitPanel.img_player3.visible = true;

            }
            // this.time.start();
        }

        //摊牌重连
        private RelinkinTanpai(data: any): void {
            let tmp: any = [];
            tmp.dwUserID = GameVO.getVo().dwUserID;
            this.playerGetFromTotal(tmp);
            QznnVO.getVo().playerstate = data["cbPlayStatus"];
            QznnVO.getVo().zhuangChairId = data["wBankerUser"];
            this.playWaitPanel.rule_difen.text = "底注：" + data.lCellScore / 100;
            this.playWaitPanel.CountDownText.text = QznnVO.getVo().RelinkTime + "";
            // this.time.start();
            QznnVO.getVo().allplayerhandcard = data["cbHandCardData"];
            QznnVO.getVo().niutype = data["niutype"];
            this.ShowAllCard();


        }

        //拼牌重连
        private RelinkinPingpai(data: any): void {
            let tmp: any = [];
            tmp.dwUserID = GameVO.getVo().dwUserID;
            this.playerGetFromTotal(tmp);
            QznnVO.getVo().zhuangChairId = data["wBankerUser"];
            QznnVO.getVo().playerstate = data["cbPlayStatus"];
            QznnVO.getVo().handCard = data["cbHandCard"];
            this.playWaitPanel.rule_difen.text = "底注：" + data.lCellScore / 100;
            for (let i = 0; i < data.lScoreTimes.length; i++) {
                if (data.lScoreTimes[i] > 0) {
                    let tmpdata: Object = new Object();
                    tmpdata["wAddScoreUser"] = i;
                    tmpdata["cbAddTimes"] = data.lScoreTimes[i]
                    this.playerAddtime(tmpdata);
                }
            }
            if (data["wBankerUser"] == QznnVO.getVo().wChairID) {
                this.playWaitPanel.player1.img_zhuang.source = "qznn_zhuang";
                this.playWaitPanel.player1.img_qiangzhuang.source = "play_qiangzhuang_title_x" + data["wBankerTimes"];
            }
            else {
                if (data["wBankerUser"] - QznnVO.getVo().wChairID > 0) {
                    this.playWaitPanel["player" + (data["wBankerUser"] - QznnVO.getVo().wChairID)].img_zhuang.source = "qznn_zhuang";
                    this.playWaitPanel["player" + (data["wBankerUser"] - QznnVO.getVo().wChairID)].img_qiangzhuang.source = "play_qiangzhuang_title_x" + data["wBankerTimes"];
                }
                else {
                    this.playWaitPanel["player" + (5 + data["wBankerUser"] - QznnVO.getVo().wChairID)].img_zhuang.source = "qznn_zhuang";
                    this.playWaitPanel["player" + (5 + data["wBankerUser"] - QznnVO.getVo().wChairID)].img_qiangzhuang.source = "play_qiangzhuang_title_x" + data["wBankerTimes"];
                }
            }
            this.ShowPlayerCard(data);
            for (let i = 0; i < data["lCombineStatus"].length; i++) {
                if (data["lCombineStatus"][i]) {
                    if (i - QznnVO.getVo().wChairID >= 0) {
                        this.playWaitPanel["img_wc" + (i - QznnVO.getVo().wChairID)].visible = true;
                        this.playWaitPanel["img_wcbg" + (i - QznnVO.getVo().wChairID)].visible = true;
                    }
                    else {
                        this.playWaitPanel["img_wc" + (5 + i - QznnVO.getVo().wChairID)].visible = true;
                        this.playWaitPanel["img_wcbg" + (5 + i - QznnVO.getVo().wChairID)].visible = true;
                    }
                }
            }
            this.playWaitPanel.CountDownText.text = QznnVO.getVo().RelinkTime + "";
            // this.time.start();
        }

        private onMyPoker_DDZClicke(event: egret.TouchEvent): void {
            if (event.currentTarget.y == 571.08) {
                if (this.Poker_DDZUpMove(parseInt(event.currentTarget.name))) {
                    event.currentTarget.y = event.currentTarget.y - 30;
                }
            }
            else if (event.currentTarget.y == 541.08) {
                this.Poker_DDZDownMove(parseInt(event.currentTarget.name));
                event.currentTarget.y = event.currentTarget.y + 30;
            }
        }

        //手牌向下移动
        private Poker_DDZDownMove(poker: number): void {
            let tmp = QznnVO.getVo().handCard[poker];
            for (let i = 0; i < this.Poker_DDZArr.length; i++) {
                if (this.Poker_DDZArr[i] == tmp) {
                    this.Poker_DDZArr.splice(i, 1);
                    break;
                }
            }
            this.PutIntoLabs();
        }

        //手牌向上移动
        private Poker_DDZUpMove(poker: number): boolean {
            if (this.Poker_DDZArr.length < 3) {
                let tmp = QznnVO.getVo().handCard[poker];
                this.Poker_DDZArr.push(tmp);
                this.PutIntoLabs();
                return true;
            }
            else {
                return false;
            }
        }

        //写入
        private PutIntoLabs(): void {
            for (let i = 1; i < 5; i++) {
                this.playWaitPanel["lab_N" + i].text = "";
            }
            for (let i = 1; i < this.Poker_DDZArr.length + 1; i++) {
                if (this.Poker_DDZArr[i - 1] % 16 >= 10) {
                    this.playWaitPanel["lab_N" + i].text = 10;
                }
                else {
                    this.playWaitPanel["lab_N" + i].text = this.Poker_DDZArr[i - 1] % 16;
                }
            }
            if (this.Poker_DDZArr.length == 3) {
                let num = 0;
                for (let i = 0; i < 3; i++) {
                    if (this.Poker_DDZArr[i] % 16 >= 10) {
                        num = num + 10;
                    }
                    else {
                        num = num + this.Poker_DDZArr[i] % 16;
                    }
                }
                this.playWaitPanel["lab_N" + 4].text = num;
                if (num % 10 == 0) {
                    this.playWaitPanel.img_jqr.source = "jqr1";
                }
                else {
                    this.playWaitPanel.img_jqr.source = "jqr";
                }
            }
        }

        //准备拼牌
        private PlayerPrepareTanpai(data: any): void {
            if (data == QznnVO.getVo().wChairID) {
                for (let i = 0; i < 5; i++) {
                    this.playWaitPanel["poker_My" + i].source = "";
                    this.playWaitPanel["poker1_" + i].source = "poker_back";
                }
                this.playWaitPanel.btn_meiniu.visible = false;
                this.playWaitPanel.btn_youniu.visible = false;
                this.playWaitPanel.lab_N1.text = ""
                this.playWaitPanel.lab_N2.text = ""
                this.playWaitPanel.lab_N3.text = ""
                this.playWaitPanel.lab_N4.text = ""
                this.Poker_DDZArr = [];
                this.playWaitPanel.group_jqr.visible = false;
                this.playWaitPanel.img_wc1.visible = true;
                this.playWaitPanel.img_wcbg1.visible = true;
            }
            if (data == QznnVO.getVo().leftChairID) {
                this.playWaitPanel.img_wc0.visible = true;
                this.playWaitPanel.img_wcbg0.visible = true;
            }
            if (data == QznnVO.getVo().rightChairID) {
                this.playWaitPanel.img_wc2.visible = true;
                this.playWaitPanel.img_wcbg2.visible = true;
            }
            if (data == QznnVO.getVo().upChairID) {
                this.playWaitPanel.img_wc3.visible = true;
                this.playWaitPanel.img_wcbg3.visible = true;
            }
        }

        private onZhunbeiClick(event: egret.TouchEvent): void {
            let obj = new Object();
            SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.QZNN, RegDataQznn.CMD_GP_UserGameReady, obj);
            this.playWaitPanel.zhunbei.visible = false;
            SoundManage.startAnniuBtnLoad();
        }

        private onBtnyouniuClick(event: egret.TouchEvent): void {
            if (this.playWaitPanel.lab_N4.text != "") {
                if (parseInt(this.playWaitPanel.lab_N4.text) % 10 == 0) {
                    let obj = { bOX: QznnVO.getVo().selfNiuState };
                    SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.QZNN, RegDataQznn.CMD_GP_UserOpenCard, obj);
                    this.playWaitPanel.btn_youniu.visible = false;
                    this.playWaitPanel.btn_meiniu.visible = false;
                    this.playWaitPanel.img_jqr.source = "jqr";
                }
                else {
                    EffectUtils.textFadeAway("拼牌错误!");
                }
            }
            else {
                EffectUtils.textFadeAway("拼牌错误!");

            }
            SoundManage.startAnniuBtnLoad();
        }

        private onBtnmeiniuClick(event: egret.TouchEvent): void {
            if (QznnVO.getVo().selfNiuState != 1 && QznnVO.getVo().selfNiuState != 0) {
                EffectUtils.textFadeAway("你有牛哦!");
            }
            else {
                let obj = { bOX: QznnVO.getVo().selfNiuState };
                SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.QZNN, RegDataQznn.CMD_GP_UserOpenCard, obj);
                this.playWaitPanel.btn_meiniu.visible = false;
                this.playWaitPanel.btn_youniu.visible = false;
            }
            SoundManage.startAnniuBtnLoad();
        }

        //时钟倒计时函数
        private TimeCutDown(): void {
            let tmp = parseInt(this.playWaitPanel.CountDownText.text);
            if (tmp > 0) {
                this.playWaitPanel.CountDownText.text = "" + (tmp - 1);
            }
            else if (tmp == 0) {
                // this.playWaitPanel.CountDownBg.visible = false;
                // this.playWaitPanel.CountDownText.visible = false;
                // this.playWaitPanel.group_xjxz.visible = false;
                this.time.stop();
                this.time.reset();
            }
        }




        private Time2CutDown(): void {
            if (QznnVO.getVo().zhuangChairId == QznnVO.getVo().wChairID) {
                EffectUtils.playDim(this.playWaitPanel.player1.img_headbg);
            }
            else {
                if (this._choseZhuang[this.conut % this._choseZhuang.length] == QznnVO.getVo().leftChairID) {
                    EffectUtils.playDim(this.playWaitPanel.player0.img_headbg);
                }
                else if (this._choseZhuang[this.conut % this._choseZhuang.length] == QznnVO.getVo().rightChairID) {
                    EffectUtils.playDim(this.playWaitPanel.player2.img_headbg);
                }
                else if (this._choseZhuang[this.conut % this._choseZhuang.length] == QznnVO.getVo().upChairID) {
                    EffectUtils.playDim(this.playWaitPanel.player3.img_headbg);
                }
            }
        }

        //时钟倒计时停止
        private TimeCutDownStop(): void {

        }


        //玩家发牌动画
        private PlayerFapaiDonghua(playernum: number, aimX: number, aimY: number): void {
            if (playernum == QznnVO.getVo().leftChairID) {
                playernum = 0
            }
            else if (playernum == QznnVO.getVo().rightChairID) {
                playernum = 2
            }
            else if (playernum == QznnVO.getVo().upChairID) {
                playernum = 3
            }
            for (let i = 0; i < 5; i++) {
                let tw = egret.Tween.get(this.playWaitPanel["poker" + playernum + "_" + i]);
                this.playWaitPanel["poker" + playernum + "_" + i].x = 640;
                this.playWaitPanel["poker" + playernum + "_" + i].y = 120;
                this.playWaitPanel["poker" + playernum + "_" + i].scaleX = 0;
                this.playWaitPanel["poker" + playernum + "_" + i].scaleY = 0;
                this.playWaitPanel["poker" + playernum + "_" + i].rotation = -90;
                this.playWaitPanel["poker" + playernum + "_" + i].visible = true;
                this.playWaitPanel["poker" + playernum + "_" + i].source = "poker_back";
                tw.wait(100 + i * 30).to({ x: aimX + i * 33, y: aimY, scaleX: 0.7, scaleY: 0.7, rotation: 0 }, 750, egret.Ease.quadOut);
            }
        }

        private SelfFapaiDonghua(data): void {
            for (let i = 0; i < 5; i++) {
                let tw = egret.Tween.get(this.playWaitPanel["poker_My" + i]);
                this.playWaitPanel["poker_My" + i].x = 640;
                this.playWaitPanel["poker_My" + i].y = 120;
                this.playWaitPanel["poker_My" + i].scaleX = 0;
                this.playWaitPanel["poker_My" + i].scaleY = 0;
                this.playWaitPanel["poker_My" + i].rotation = -90;
                this.playWaitPanel["poker_My" + i].visible = true;
                this.playWaitPanel["poker_My" + i].source = "poker_back";
                tw.wait(100 + i * 30).to({ x: 479.97 + i * 81.58, y: 571.08, scaleX: 1, scaleY: 1, rotation: 0 }, 750, egret.Ease.quadOut).call(() => {
                    this.playWaitPanel["poker_My" + i].source = Global.getPokerById(data[i]);
                });
            }
        }

        //显示玩家手牌
        public ShowPlayerCard(data): void {
            QznnVO.getVo().handCard = data["cbHandCardData"][QznnVO.getVo().wChairID];
            QznnVO.getVo().selfNiuState = data["cbCardType"][QznnVO.getVo().wChairID];
            if (QznnVO.getVo().wChairID != null) {
                this.SelfFapaiDonghua(data["cbHandCardData"][QznnVO.getVo().wChairID]);
                this.playWaitPanel.group_jqr.visible = true;
                this.playWaitPanel.btn_meiniu.visible = true;
                this.playWaitPanel.btn_youniu.visible = true;
            }
            if (QznnVO.getVo().leftChairID != null) {
                this.PlayerFapaiDonghua(QznnVO.getVo().leftChairID, 55.41, 343.52);
            }
            if (QznnVO.getVo().rightChairID != null) {
                this.PlayerFapaiDonghua(QznnVO.getVo().rightChairID, 1053.1, 343.52);
            }
            if (QznnVO.getVo().upChairID != null) {
                this.PlayerFapaiDonghua(QznnVO.getVo().upChairID, 656.96, 65.56);
            }
            // if(QznnVO.getVo().leftChairID)
            // // for (let i = 0; i < QznnVO.getVo().handCard.length; i++) {
            // //     this.playWaitPanel["poker_My" + i].source = Global.getPokerById(QznnVO.getVo().handCard[i]);
            // // }
            // for (let i = 0; i < QznnVO.getVo().playerstate.length; i++) {
            //     if (QznnVO.getVo().playerstate[i]) {
            //         if (i - QznnVO.getVo().wChairID > 0) {
            //             if (i - QznnVO.getVo().wChairID == 1) {
            //                 this.PlayerFapaiDonghua(i - QznnVO.getVo().wChairID, 263, 313);
            //             }
            //             else if (i - QznnVO.getVo().wChairID == 2) {
            //                 this.PlayerFapaiDonghua(i - QznnVO.getVo().wChairID, 320, 155);
            //             }
            //             else if (i - QznnVO.getVo().wChairID == 3) {
            //                 this.PlayerFapaiDonghua(i - QznnVO.getVo().wChairID, 784, 155);
            //             }
            //             else if (i - QznnVO.getVo().wChairID == 4) {
            //                 this.PlayerFapaiDonghua(i - QznnVO.getVo().wChairID, 825, 313);
            //             }
            //         }
            //         else if (i - QznnVO.getVo().wChairID < 0) {
            //             if (5 + (i - QznnVO.getVo().wChairID) == 1) {
            //                 this.PlayerFapaiDonghua(5 + (i - QznnVO.getVo().wChairID), 263, 313);
            //             }
            //             else if (5 + (i - QznnVO.getVo().wChairID) == 2) {
            //                 this.PlayerFapaiDonghua(5 + (i - QznnVO.getVo().wChairID), 320, 155);
            //             }
            //             else if (5 + (i - QznnVO.getVo().wChairID) == 3) {
            //                 this.PlayerFapaiDonghua(5 + (i - QznnVO.getVo().wChairID), 784, 155);
            //             }
            //             else if (5 + (i - QznnVO.getVo().wChairID) == 4) {
            //                 this.PlayerFapaiDonghua(5 + (i - QznnVO.getVo().wChairID), 825, 313);
            //             }
            //         }
            //     }
            // }

            // this.playWaitPanel.fanpai.visible = true;
            // this.playWaitPanel.btn_meiniu.visible = true;
            // this.playWaitPanel.btn_youniu.visible = true;

            this.time.stop();
            this.time.reset();
            this.playWaitPanel.CountDownBg.visible = true;
            this.playWaitPanel.CountDownText.visible = true;
            this.playWaitPanel.CountDownText.text = QznnVO.getVo().tanpaitime + "";
            this.time.start();
        }

        //摊牌
        public ShowAllCard(): void {
            this.playWaitPanel.CountDownBg.visible = false;
            this.playWaitPanel.CountDownText.visible = false;
            this.time.stop();
            var thisObj = this;
            let num = 0;
            if (QznnVO.getVo().typeAni > 0) {
                let aniActName = "";
                let frameName = "";
                if (QznnVO.getVo().typeAni == 1) {
                    aniActName = "qznn_tc";
                    frameName = "tc"
                }
                else if (QznnVO.getVo().typeAni == 2) {
                    aniActName = "qznn_tp";
                    frameName = "tp"
                }
                else if (QznnVO.getVo().typeAni == 3) {
                    aniActName = "qznn_sl";
                    frameName = "sl"
                }
                var data = RES.getRes("qznnr_json");
                var txtr = RES.getRes("qznnr");
                var mcFactory: egret.MovieClipDataFactory = new egret.MovieClipDataFactory(data, txtr);
                var mc1: egret.MovieClip = new egret.MovieClip(mcFactory.generateMovieClipData(aniActName));
                thisObj.playWaitPanel.addChild(mc1)
                mc1.gotoAndPlay(frameName, 4);
                mc1.addEventListener(egret.Event.COMPLETE, (e: egret.Event) => {
                    if (thisObj.playWaitPanel.contains(g)) {
                        thisObj.playWaitPanel.removeChild(g)
                        this.aniTime = 3;
                    }
                }, this);
                var g = new eui.Group();
                g.addChild(mc1);
                g.width = 400//引擎缺陷，无法得到egret.MovieClip的实时宽高，想要知道最大宽度只能到动画资源去看，更换动画资源后需要更改此值否则动画无法居中播放
                g.horizontalCenter = "0";
                g.y = 0.25 * GameConfig.curHeight();
                thisObj.playWaitPanel.addChild(g)
            }
            else {
                this.aniTime = 2;
            }
            if (QznnVO.getVo().wChairID !== null) {
                for (let j = 0; j < 5; j++) {
                    thisObj.playWaitPanel["poker1_" + j].source = Global.getPokerById(QznnVO.getVo().allplayerhandcard[QznnVO.getVo().wChairID][j]);
                }
                thisObj.playWaitPanel.niu_type_my.source = "n" + QznnVO.getVo().niutype[QznnVO.getVo().wChairID];
                thisObj.playWaitPanel["img_wc1"].visible = false;
                thisObj.playWaitPanel["img_wcbg1"].visible = false;
                thisObj.playWaitPanel.goldNum_player1.text = Global.getmeishufen(QznnVO.getVo().my_win / 100);
                EffectUtils.flyObj(thisObj.playWaitPanel.goldNum_player1)
                thisObj.playWaitPanel.player1.blab_score.text = thisObj.SortGold(QznnVO.getVo().lUserScore + QznnVO.getVo().my_win) + ""
            }
            if (QznnVO.getVo().leftChairID !== null) {
                for (let j = 0; j < 5; j++) {
                    thisObj.playWaitPanel["poker0_" + j].source = Global.getPokerById(QznnVO.getVo().allplayerhandcard[QznnVO.getVo().leftChairID][j]);
                }
                thisObj.playWaitPanel.niu_type_left.source = "n" + QznnVO.getVo().niutype[QznnVO.getVo().leftChairID];
                thisObj.playWaitPanel["img_wc0"].visible = false;
                thisObj.playWaitPanel["img_wcbg0"].visible = false;
                thisObj.playWaitPanel.goldNum_player0.text = Global.getmeishufen(QznnVO.getVo().left_win / 100);
                EffectUtils.flyObj(thisObj.playWaitPanel.goldNum_player0)
                thisObj.playWaitPanel.player0.blab_score.text = thisObj.SortGold(QznnVO.getVo().leftGlod + QznnVO.getVo().left_win) + "";

            }
            if (QznnVO.getVo().rightChairID !== null) {
                for (let j = 0; j < 5; j++) {
                    thisObj.playWaitPanel["poker2_" + j].source = Global.getPokerById(QznnVO.getVo().allplayerhandcard[QznnVO.getVo().rightChairID][j]);
                }
                thisObj.playWaitPanel.niu_type_right.source = "n" + QznnVO.getVo().niutype[QznnVO.getVo().rightChairID];
                thisObj.playWaitPanel["img_wc2"].visible = false;
                thisObj.playWaitPanel["img_wcbg2"].visible = false;
                thisObj.playWaitPanel.goldNum_player2.text = Global.getmeishufen(QznnVO.getVo().right_win / 100);
                EffectUtils.flyObj(thisObj.playWaitPanel.goldNum_player2)
                thisObj.playWaitPanel.player2.blab_score.text = thisObj.SortGold(QznnVO.getVo().rightGlod + QznnVO.getVo().right_win) + "";
            }
            if (QznnVO.getVo().upChairID !== null) {
                for (let j = 0; j < 5; j++) {
                    thisObj.playWaitPanel["poker3_" + j].source = Global.getPokerById(QznnVO.getVo().allplayerhandcard[QznnVO.getVo().upChairID][j]);
                }
                thisObj.playWaitPanel.niu_type_up.source = "n" + QznnVO.getVo().niutype[QznnVO.getVo().upChairID];
                thisObj.playWaitPanel["img_wc3"].visible = false;
                thisObj.playWaitPanel["img_wcbg3"].visible = false;
                thisObj.playWaitPanel.goldNum_player3.text = Global.getmeishufen(QznnVO.getVo().up_win / 100);
                EffectUtils.flyObj(thisObj.playWaitPanel.goldNum_player3)
                thisObj.playWaitPanel.player3.blab_score.text = thisObj.SortGold(QznnVO.getVo().upGlod + QznnVO.getVo().up_win) + ""
            }

            this.playWaitPanel.btn_meiniu.visible = false;
            this.playWaitPanel.btn_youniu.visible = false;



        }

        //玩家座位号
        private getPlayerSit(ChairID: number): string {
            let tmp = "";
            if (ChairID == QznnVO.getVo().wChairID) {
                tmp = "player1";
            }
            else {
                if (ChairID - QznnVO.getVo().wChairID > 0) {
                    tmp = "player" + (ChairID - QznnVO.getVo().wChairID);
                }
                else if (ChairID - QznnVO.getVo().wChairID < 0) {
                    tmp = "player" + (5 + ChairID - QznnVO.getVo().wChairID);
                }
            }
            return tmp;
        }


        //清空牌桌
        private ClearTabel(): void {
            this.playWaitPanel.img_jqr.source = "jqr";
            QznnVO.getVo().typeAni = 0;
            QznnVO.getVo().zhuangID = null;
            this.playWaitPanel.niu_type_my.source = "";
            this.playWaitPanel.niu_type_left.source = "";
            this.playWaitPanel.niu_type_up.source = "";
            this.playWaitPanel.niu_type_right.source = "";
            for (let i = 0; i < 4; i++) {
                for (let j = 0; j < 5; j++) {
                    this.playWaitPanel["poker" + i + "_" + j].source = "";
                }
                this.playWaitPanel["img_wc" + i].visible = false;
                this.playWaitPanel["img_wcbg" + i].visible = false;
                this.playWaitPanel["img_player" + i].source = "";
                this.playWaitPanel["goldNum_player" + i].text = "";
            }
            for (let i = 0; i < 5; i++) {
                this.playWaitPanel["poker_My" + i].source = "";
            }
            this.playWaitPanel.player0.img_zhuang.visible = false;
            this.playWaitPanel.player1.img_zhuang.visible = false;
            this.playWaitPanel.player2.img_zhuang.visible = false;
            this.playWaitPanel.player3.img_zhuang.visible = false;

            this.playWaitPanel.player0.img_headbg.visible = false;
            this.playWaitPanel.player1.img_headbg.visible = false;
            this.playWaitPanel.player2.img_headbg.visible = false;
            this.playWaitPanel.player3.img_headbg.visible = false;

            for (let i = 0; i < 5; i++) {
                this.playWaitPanel["poker_My" + i].y = 567;
            }
            this.playWaitPanel.niu_type_my.source = "";
        }

        //叫分点击事件
        private clickBet(event: egret.TouchEvent): void {
            let a = Number(event.$currentTarget.name) * 5 * Number(QznnVO.getVo().difen)
            let obj = {
                cbAddTimes: a,
            }
            SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.QZNN, RegDataQznn.CMD_GP_UserAddScore, obj);
        }

        //闲家下注
        private StartXianJiaXiaZhu(data: any): void {
            if (data["wAddScoreUser"] == QznnVO.getVo().wChairID) {
                this.playWaitPanel.img_player1.source = "qznn_bet_" + (Number(data["cbAddTimes"]) / Number(QznnVO.getVo().difen));
                this.playWaitPanel.img_player1.visible = true;
                this.playWaitPanel.jiaofen_group.visible = false;
            }
            else if (data["wAddScoreUser"] == QznnVO.getVo().leftChairID) {
                this.playWaitPanel.img_player0.source = "qznn_bet_" + (Number(data["cbAddTimes"]) / Number(QznnVO.getVo().difen));
                this.playWaitPanel.img_player0.visible = true;
            }
            else if (data["wAddScoreUser"] == QznnVO.getVo().rightChairID) {
                this.playWaitPanel.img_player2.source = "qznn_bet_" + (Number(data["cbAddTimes"]) / Number(QznnVO.getVo().difen));
                this.playWaitPanel.img_player2.visible = true;
            }
            else if (data["wAddScoreUser"] == QznnVO.getVo().upChairID) {
                this.playWaitPanel.img_player3.source = "qznn_bet_" + (Number(data["cbAddTimes"]) / Number(QznnVO.getVo().difen));
                this.playWaitPanel.img_player3.visible = true;
            }
        }

        //开始抢庄
        private startQiangzhuang(): void {
            this.playWaitPanel.group_xjxz.visible = true;
            for (let i = 1; i < 2; i++) {
                this.playWaitPanel["btn_" + i].img_btn.source = "qiang_" + i;
                this.playWaitPanel["btn_" + i].name = i + "";
                this.playWaitPanel["btn_" + i].lab_text.text = "";
                this.playWaitPanel["btn_" + i].GameQiangUse();
                this.playWaitPanel["btn_" + i].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onQiangzhuang, this);
            }
            this.playWaitPanel.btn_0.img_btn.source = "buqiang";
            this.playWaitPanel.btn_0.name = 0 + "";
            this.playWaitPanel.btn_0.lab_text.text = "";
            this.playWaitPanel.btn_0.GameQiangUse();
            this.playWaitPanel.btn_0.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onQiangzhuang, this);
            this.playWaitPanel.CountDownBg.visible = true;
            this.playWaitPanel.CountDownText.visible = true;
            this.playWaitPanel.CountDownText.text = QznnVO.getVo().qiangzhuangtime + "";
            // this.playWaitPanel.rule_difen.text = 
            // this.time.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.TimeCutDownStop, this);
            this.time.stop();
            this.time.reset();
            this.time.start();
        }

        private onQiangzhuang(event: egret.TouchEvent): void {
            let obj = new Object();
            // this.isClicke = false;

            obj["dwUserRight"] = parseInt(event.currentTarget.name);
            SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.QZNN, RegDataQznn.CMD_GP_UserCallBanker, obj);
            this.playWaitPanel.group_xjxz.visible = false;
            SoundManage.startAnniuBtnLoad();
        }

        private onStartXianJiaXiaZhu(event: egret.TouchEvent): void {
            let obj = new Object();
            // this.isClicke = true;
            obj["cbAddTimes"] = parseInt(event.currentTarget.name);
            SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.QZNN, RegDataQznn.CMD_GP_UserAddScore, obj);
            this.playWaitPanel.group_xjxz.visible = false;
            SoundManage.startAnniuBtnLoad();
        }
        // 玩家叫分
        private playerAddtime(data: any): void {
            if (data["cbSelectBanker"] != 0) {
                this.qiangArr.push(data["cbBankerUser"])
            }
            if (data) {
                if (data["cbBankerUser"] == QznnVO.getVo().wChairID) {
                    this.playWaitPanel.player1.img_qiangzhuang.source = "play_qiangzhuang_title_x" + data["cbSelectBanker"];
                    this.playWaitPanel.player1.img_qiangzhuang.visible = true;
                    this.playWaitPanel.group_xjxz.visible = false;
                    for (let i = 0; i < 2; i++) {
                        this.playWaitPanel["btn_" + i].removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onStartXianJiaXiaZhu, this);
                    }
                    this.isXiaZhuWait = false;
                }
                else if (data["cbBankerUser"] == QznnVO.getVo().leftChairID) {
                    this.playWaitPanel.player0.img_qiangzhuang.source = "play_qiangzhuang_title_x" + data["cbSelectBanker"];
                    this.playWaitPanel.player0.img_qiangzhuang.visible = true;

                }
                else if (data["cbBankerUser"] == QznnVO.getVo().upChairID) {
                    this.playWaitPanel.player3.img_qiangzhuang.y = 147;
                    this.playWaitPanel.player3.img_qiangzhuang.source = "play_qiangzhuang_title_x" + data["cbSelectBanker"];
                    this.playWaitPanel.player3.img_qiangzhuang.visible = true;

                }
                else if (data["cbBankerUser"] == QznnVO.getVo().rightChairID) {
                    this.playWaitPanel.player2.img_qiangzhuang.source = "play_qiangzhuang_title_x" + data["cbSelectBanker"];
                    this.playWaitPanel.player2.img_qiangzhuang.visible = true;
                }

            }
        }
        //抢庄重连
        private RelinkinQiangZHuang(data: any): void {
            // let tmp: any = [];
            // tmp.dwUserID = GameVO.getVo().dwUserID;
            // this.playerGetFromTotal(tmp);
            this.playWaitPanel.player0.img_qiangzhuang.visible = true;
            this.playWaitPanel.player2.img_qiangzhuang.visible = true;
            this.playWaitPanel.player3.img_qiangzhuang.visible = true;
            QznnVO.getVo().playerstate = data["cbPlayStatus"];
            this.playWaitPanel.rule_difen.text = "底注：" + data.lCellScore / 100;
            this.playWaitPanel.CountDownText.text = QznnVO.getVo().RelinkTime + "";
            this.time.start();
        }

        //抢庄返回
        private handleSinglePlayerQiangZhuangReturn(data: any): void {
            QznnVO.getVo().zhuangID = data["wBankerUser"];
            var thisObj = this;
            let arr = [];
            if (this.qiangArr.length == 0) {
                thisObj.qiangArr.push(data["wBankerUser"]);
            }
            // console.log(QznnVO.getVo().wChairID, QznnVO.getVo().leftChairID, QznnVO.getVo().rightChairID, QznnVO.getVo().upChairID, data)
            for (let i = 0; i < thisObj.qiangArr.length; i++) {
                if (thisObj.qiangArr[i] == QznnVO.getVo().wChairID) {
                    arr.push(thisObj.playWaitPanel.player1.img_headbg)
                }
                else if (thisObj.qiangArr[i] == QznnVO.getVo().leftChairID) {
                    arr.push(thisObj.playWaitPanel.player0.img_headbg)
                }
                else if (thisObj.qiangArr[i] == QznnVO.getVo().rightChairID) {
                    arr.push(thisObj.playWaitPanel.player2.img_headbg)
                }
                else if (thisObj.qiangArr[i] == QznnVO.getVo().upChairID) {
                    arr.push(thisObj.playWaitPanel.player3.img_headbg)
                }
            }
            let num = 0, num2 = 0, delayTime = 400 / arr.length;
            let t = egret.setInterval(() => {
                arr[num].visible = true;
                EffectUtils.playDim(arr[num])
                num++
                if (num % arr.length == 0) {
                    num = 0
                    num2++
                }
                if (num2 > 3) {//限制3轮
                    if (data["wBankerUser"] != QznnVO.getVo().leftChairID) {
                        thisObj.playWaitPanel.player0.img_zhuang.visible = false
                        thisObj.playWaitPanel.player0.img_headbg.visible = false
                    }
                    else {
                        thisObj.playWaitPanel.player0.img_zhuang.visible = true;
                        thisObj.playWaitPanel.player0.img_headbg.visible = true;
                    }
                    if (data["wBankerUser"] != QznnVO.getVo().upChairID) {
                        thisObj.playWaitPanel.player3.img_zhuang.visible = false
                        thisObj.playWaitPanel.player3.img_headbg.visible = false
                    }
                    else {
                        thisObj.playWaitPanel.player3.img_zhuang.visible = true;
                        thisObj.playWaitPanel.player3.img_headbg.visible = true;
                    }
                    if (data["wBankerUser"] != QznnVO.getVo().rightChairID) {
                        thisObj.playWaitPanel.player2.img_zhuang.visible = false
                        thisObj.playWaitPanel.player2.img_headbg.visible = false
                    }
                    else {
                        thisObj.playWaitPanel.player2.img_zhuang.visible = true;
                        thisObj.playWaitPanel.player2.img_headbg.visible = true;
                    }
                    if (data["wBankerUser"] != QznnVO.getVo().wChairID) {
                        thisObj.playWaitPanel.player1.img_zhuang.visible = false
                        thisObj.playWaitPanel.player1.img_headbg.visible = false
                    }
                    else {
                        thisObj.playWaitPanel.player1.img_zhuang.visible = true;
                        thisObj.playWaitPanel.player1.img_headbg.visible = true;
                    }
                    if (data["wBankerUser"] - QznnVO.getVo().wChairID == 0) {
                        thisObj.playWaitPanel.jiaofen_group.visible = false;
                    }
                    else {
                        if (10 * QznnVO.getVo().difen < QznnVO.getVo().maxScore && QznnVO.getVo().lUserScore > 40 * QznnVO.getVo().difen) {
                            thisObj.playWaitPanel.jiao_2.touchEnabled = true;
                            thisObj.playWaitPanel.jiao_2.source = "jiao_10"
                        }
                        else {
                            thisObj.playWaitPanel.jiao_2.touchEnabled = false;
                            thisObj.playWaitPanel.jiao_2.source = "jiaoh_10"
                        }
                        if (15 * QznnVO.getVo().difen < QznnVO.getVo().maxScore && QznnVO.getVo().lUserScore > 60 * QznnVO.getVo().difen) {
                            thisObj.playWaitPanel.jiao_3.touchEnabled = true;
                            thisObj.playWaitPanel.jiao_3.source = "jiao_15"
                        }
                        else {
                            thisObj.playWaitPanel.jiao_3.touchEnabled = false;
                            thisObj.playWaitPanel.jiao_3.source = "jiaoh_15"
                        }
                        if (20 * QznnVO.getVo().difen < QznnVO.getVo().maxScore && QznnVO.getVo().lUserScore > 80 * QznnVO.getVo().difen) {
                            thisObj.playWaitPanel.jiao_4.touchEnabled = true;
                            thisObj.playWaitPanel.jiao_4.source = "jiao_20"
                        }
                        else {
                            thisObj.playWaitPanel.jiao_4.touchEnabled = false;
                            thisObj.playWaitPanel.jiao_4.source = "jiaoh_20"
                        }
                        thisObj.playWaitPanel.jiaofen_group.visible = true;
                    }
                    thisObj.qiangArr = [];
                    thisObj.playWaitPanel.player0.img_qiangzhuang.visible = false;
                    thisObj.playWaitPanel.player1.img_qiangzhuang.visible = false;
                    thisObj.playWaitPanel.player2.img_qiangzhuang.visible = false;
                    thisObj.playWaitPanel.player3.img_qiangzhuang.visible = false;
                    thisObj.time.stop();
                    thisObj.time.reset();
                    thisObj.time.start();
                    thisObj.playWaitPanel.CountDownBg.visible = true;
                    thisObj.playWaitPanel.CountDownText.visible = true;
                    thisObj.playWaitPanel.CountDownText.text = QznnVO.getVo().jiazhutime + "";
                    egret.clearInterval(t)
                }
            }, this, delayTime)
            // game.AppFacade.instance.sendNotification(PanelNotify.QZNN.XIANJIA_XIAZHU, obj);

            if (data["wBankerUser"] - QznnVO.getVo().wChairID == 0) {
                for (let i = 0; i < 2; i++) {
                    this.playWaitPanel["btn_" + i].removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onQiangzhuang, this);
                }
            }

        }
        //处理房间信息
        public showRoomData() {
            this.playWaitPanel.rule_difen.text = "底注:" + QznnVO.getVo().difen;
        }

        //换桌
        private huanzhuoClick(eve: egret.TouchEvent) {
            SoundManage.startAnniuBtnLoad();
            QznnVO.getVo().huanzhuoClick = true;
            SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.QZNN, RegDataQznn.CMD_GP_ModifyRoom, {});
        }
        //准备
        private zhunbeiClick(eve: egret.TouchEvent) {
            this.ClearTabel();
            this.aniTime = 0;
            this.playWaitPanel.CountDownBg.visible = false;
            this.playWaitPanel.CountDownText.visible = false;
            // this.playWaitPanel.rule_difen.text = 
            // this.time.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.TimeCutDownStop, this);
            this.time.stop();
            SoundManage.startAnniuBtnLoad();
            EffectUtils.playDim(eve.currentTarget);
            // let obj = new Object();
            // obj["wVisit"] = 0
            // obj["wVersion"] = 101122049
            // obj["wGameVersion"] = 101122049;
            SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.QZNN, RegDataQznn.CMD_GP_StartGame, {});
        }
        //获取本桌玩家
        private playerGetFromTotal(data: any) {
            this._playerGroup = [];
            for (let i = 0; i < QznnVO.getVo().otherPlayer.length; i++) {
                if (QznnVO.getVo().otherPlayer[i].wTableID == QznnVO.getVo().wTableID) {
                    this._playerGroup.push(QznnVO.getVo().otherPlayer[i]);
                }
            }
            for (let i = 0; i < this._playerGroup.length; i++) {
                // if (this._playerGroup[i].dwUserID == data.dwUserID) {
                // }
            }

            if (data.dwUserID == GameVO.getVo().dwUserID) {
                // this.selfsit();
                // return;
            }
        }

        //玩家离开
        private playerLeave(data: any): void {
            let tmp = 0;
            for (let i = 0; i < this._playerGroup.length; i++) {
                if (data["dwUserID"] == this._playerGroup[i].dwUserID) {
                    if ((QznnVO.getVo().wChairID - this._playerGroup[i].wChairID) > 0) {
                        this.playWaitPanel["player" + (5 - (QznnVO.getVo().wChairID - this._playerGroup[i].wChairID))].visible = false;
                    }
                    else if ((QznnVO.getVo().wChairID - this._playerGroup[i].wChairID) < 0) {
                        this.playWaitPanel["player" + (0 - (QznnVO.getVo().wChairID - this._playerGroup[i].wChairID))].visible = false;
                    }
                    tmp = i;
                }
            }
            for (let i = 0; i < QznnVO.getVo().otherPlayer.length; i++) {
                if (data["dwUserID"] == QznnVO.getVo().otherPlayer[i].dwUserID) {
                    QznnVO.getVo().otherPlayer.splice(i, 1);
                }
            }
            this._playerGroup.splice(tmp, 1);
        }

        //自己落座
        private selfsit(): void {
            this.playWaitPanel.player1.lab_name.text = GameVO.getVo().szNickName;
            this.playWaitPanel.player1.img_head.source = "special_" + (GameVO.getVo().wFaceID % 15);
            this.playWaitPanel.player1.blab_score.text = this.SortGold(QznnVO.getVo().lUserScore) + "";
            this.playWaitPanel.img_player1.source = "";
            this.playWaitPanel.player1.init();
            this.playWaitPanel.zhunbei.visible = true;
        }


        //离开房间发起
        private exitRoomSend(eve: egret.TouchEvent) {
            SoundManage.startAnniuBtnLoad();
            EffectUtils.playDim(eve.currentTarget);
        }
        //点击下拉菜单
        private menu_click() {
            if (this.playWaitPanel.menu_button.name == "on") {//收起菜单
                egret.Tween.removeTweens(this.playWaitPanel.menu_button)
                egret.Tween.removeTweens(this.playWaitPanel.menu_group)
                this.playWaitPanel.menu_button.name = "off"
                egret.Tween.get(this.playWaitPanel.menu_button).to({ rotation: 0 }, 300)
                egret.Tween.get(this.playWaitPanel.menu_group).to({ x: -260 }, 300).call((menu_group: eui.Group) => {
                    menu_group.visible = false;
                }, this, [this.playWaitPanel.menu_group])
            } else {                                      //弹出菜单
                egret.Tween.removeTweens(this.playWaitPanel.menu_button)
                egret.Tween.removeTweens(this.playWaitPanel.menu_group)
                this.playWaitPanel.menu_button.name = "on"
                this.playWaitPanel.menu_group.visible = true;
                egret.Tween.get(this.playWaitPanel.menu_button).to({ rotation: 90 }, 300)
                egret.Tween.get(this.playWaitPanel.menu_group).to({ x: 0 }, 300)
            }
        }
        //点击设置
        private setClick() {
            SoundManage.startAnniuBtnLoad();
            this.menu_click();
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_SETTING)
        }
        //点击帮助
        private helpClick() {
            SoundManage.startAnniuBtnLoad();
            this.menu_click();
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_HELP_QZNN)
        }
        //点击反馈
        private fankuiClick() {
            SoundManage.startAnniuBtnLoad();
            this.menu_click();
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_FANKUI, InstructionsEnum.GAME_TYPE_NAME.QZNN)
        }
        //点击记录
        private jiluClick() {
            SoundManage.startAnniuBtnLoad();
            this.menu_click();
            var obj = {
                gameType: InstructionsEnum.GAME_TYPE_NAME.QZNN,
                roomType: InstructionsEnum.LEVEL_GAME
            }
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_JILU, JSON.stringify(obj))
        }


        //离开游戏
        private exitClick() {
            SoundManage.startAnniuBtnLoad();
            this.menu_click();
            if (QznnVO.getVo().myGameStatus == 1) {
                let obj = new Object();
                obj[InstructionsEnum.TEXT] = "请等待游戏结束后离开！";
                game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_TIP, obj);
            } else {
                let obj = new Object();
                obj[InstructionsEnum.CODE] = PanelNotify.QZNN.CLOSE_PLAY_GAME;
                obj[InstructionsEnum.TEXT] = "确定要离开游戏吗？";
                game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_TIP, obj);
            }
        }



        private onHelpClick(eve: egret.TouchEvent) {
            SoundManage.startAnniuBtnLoad();
            EffectUtils.playDim(eve.currentTarget);
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_HELP_QZNN);
        }
    }
}

